<?php session_start();
include "../conexao.php";

if (!isset($_SESSION["txt_login"]))
{ print "<script type = 'text/javascript'> location.href = 'index.php'</script>"; exit();}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html;charset=iso-8859-1" />
<title>&Aacute;rea Administrativa</title>

<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript">

try{
xmlhttp = new XMLHttpRequest();
}
catch(ee){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E){
xmlhttp = false;
}
}
}

function abrePesquisa(arquivo,metodo){
xmlhttp.open(metodo,arquivo);
xmlhttp.onreadystatechange=conteudo
xmlhttp.send(null)
}

function conteudo() {
document.getElementById('conteudo').innerHTML="carregando... ";
if (xmlhttp.readyState==4){
document.getElementById('conteudo').innerHTML=xmlhttp.responseText
}
}<!--<img src='images/indicator_verybig.gif' width='100' alt=''/> -->




</script>
</head>

<body>

<div id="todo">
	<div id="topo"></div>

<div id="meio">
  <div id="conteudo">
		<div id="miolo">
			<div class="secao_miolo">
			  <div id="conteudo">
<?php 
$pagina = $_GET["pagina"];

 if($pagina=="") {
$pagina="1";
}
$maximo = 1;

$inicio=$pagina-1;
$inicio=$maximo*$inicio;

	 $sql = mysql_query("SELECT * FROM contato ORDER BY id_contato DESC LIMIT $inicio, $maximo");
	$cont = mysql_num_rows($sql);
	if ($cont > 0 ){
			  while ($linha = mysql_fetch_array($sql)) { 
	
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="98%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><div align="right" class="style7"><a href="javascript:history.back()"></a></div></td>
      </tr>
      <tr>
        <td bgcolor="#CCCCCC" class="meio"><table width="100%" border="0" cellspacing="1" cellpadding="5">
          <tr>
            <td width="55%" bgcolor="#FAFBCA">N&deg;: <?php echo $linha['id_contato'];?></td>
            
            <td colspan="3" bgcolor="#FAFBCA"><strong>&nbsp;</strong></td>
            </tr>
        
          <tr>
            <td bgcolor="#FAFBCA"><strong>Nome: </strong><?php echo $linha['nome'];?></td>
            <td colspan="2" bgcolor="#FAFBCA"><strong>&nbsp;Telefone: <?php echo $linha['telefone'] ?></strong></td>
            <td width="19%" bgcolor="#FAFBCA"><strong>DDD: <?php echo $linha['ddd'] ?></strong></td>
          </tr>
          <tr>
            <td bgcolor="#FAFBCA"><strong>Email: <?php echo $linha['email'];?>&nbsp;</strong></td>
            <td colspan="2" bgcolor="#FAFBCA"">&nbsp;</td>
            <td bgcolor="#FAFBCA""><strong>Data: <?php //echo $linha['data'];
		echo date("d/m/Y", strtotime("".$linha['data'].""));
		echo "<br>";
		echo $linha['hora'];
		?></strong></td>
          </tr>
          <tr>
            <td colspan="4" bgcolor="#FAFBCA">
              <table width="100%" border="0">
                <tr>
                  <td><table width="107%" border="0">
                    <tr>
                      <td width="28%"><img src="imagens/excluir.gif" onclick='confirmar_exclusao_contato("acao=Excluir&amp;id=<?php echo $linha['id_contato'] ?>")'></td>
                      <td width="24%">&nbsp;</td>
                      <td width="27%">&nbsp;</td>
                      <td width="21%">&nbsp;</td>
                    </tr>
                  </table></td>
                </tr>
              </table></td>
            </tr>
         
         
          <tr>
            <td colspan="4" bgcolor="#FAFBCA"><strong>Mensagem: &nbsp;</strong>
              <table width="100%" border="0">
                <tr>
                  <td><strong><?php echo $linha['mensagem'] ?></strong></td>
                </tr>
              </table></td>
            </tr>
          
        </table>
        <?php }}else echo "<font color=red size=3 >N&atilde;o h&aacute; mensagens</font>";?></td>
      </tr>
      <tr>
        <td><p>
          <?php 
$menos=$pagina-1;
$mais=$pagina+1;
$p_ini=$mais-1;
$p_ini=$maximo*$p_ini;
$p_query = mysql_query("SELECT id_contato FROM contato");
$total = mysql_num_rows($p_query);

$ver = $total%$maximo;
$ver3 = $maximo/2;
if($ver>0){ $qtde_paginas = number_format($total/$maximo); }  else{ $qtde_paginas = $total/$maximo; }
if($ver<$ver3){ $qtde_paginas = number_format($total/$maximo+1); }
if($ver==0){ $qtde_paginas = number_format($total/$maximo); } 


	     $qtde_links_por_pagina=6;

 echo "<span class=paginacao><a href=principal.php?link=28&pagina=1>primeira p&aacute;gina</a></span>";
$i = $pagina - $qtde_links_por_pagina;

while ($i <= $pagina - 1)
		 {
		     if($i>0)
			 {
			    echo "<span class=paginacao><a href=principal.php?link=28&pagina=$i>$i</a></span>";
			 }                             
			 $i++;
		 }

  echo "<span class=paginacao2>$pagina</span>";
 
         $i = $pagina + 1;
		 while($i<=$pagina + $qtde_links_por_pagina)  
		 {
		     if($i<$qtde_paginas)
			 {
			 echo "<span class=paginacao><a href=principal.php?link=28&pagina=$i>$i</a></span>
			                             
						";
			 }
			 $i++;
		 }
		echo "<span class=paginacao><a href=principal.php?link=28&pagina=$qtde_paginas>&uacute;tima pagina p&aacute;gina</a></span>";
	
	?>
        </p>
          <p>&nbsp;</p>
          </td>
      <tr><td><div align="right" class="style7"><a href="javascript:history.back()"><font size="2" color="red"><!--Voltar --></font></a></div></td><tr></tr>
    </table></td>
  </tr>
</table>
<p>&nbsp;</p></div>
		  </div>
			</div></div>
		<div style="clear: both;"></div>
	</div>

	<div id="rodape">
		<div id="rodape_direita"></div>
  </div>
</div>

</body>
</html>